import java.util.HashMap;
import java.util.Map;

public class Solution454 {
    public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
        Map<Integer,Integer> map=new HashMap<>();
        for (int i=0;i<nums3.length;i++){
            for (int j=0;j<nums4.length;j++){
                map.put(nums3[i]+nums4[j],map.getOrDefault(nums3[i]+nums4[j],0)+1);
            }
        }
        int ans=0;
        for (int i=0;i<nums1.length;i++){
            for (int j=0;j<nums2.length;j++){
                ans=ans+map.getOrDefault(-nums1[i]-nums2[j],0);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution454().fourSumCount(new int[]{1,2},new int[]{-2,-1},new int[]{-1,2},new int[]{0,2}));
    }
}
